#include<stdio.h>
#include<string.h>
#include<stdlib.h>

void substring(int start, int stop, const char *text)
{
   printf("%.*s", stop - start, &text[start]);
}


int main(){

	int i=0;
	FILE *fp;
	//char d1[80], d2[80],d3[80], d4[80], d5[80], d6[80],d7[80], d8[80], d9[80], d10[80];
	char line[256];
	char *list[]={"20080502-log", "20080611-log", "20080618-log"};	

	while(list[i]){
	//for(i=0; i<3; i++){
		if((fp = fopen(list[i],"r")) == NULL){
			printf("\nCannot file open\n");
			exit(-1);
		}
		while(fgets(line,sizeof(line),fp) !=NULL)
		{
			if(strncmp(line,"WX200 ff:",strlen("WX200")) == 0){
				//sscanf(line,"%s %s %s %s %s %s",d1,d2,d3,d4,d5,d6);
				//printf("\nTime :%s %s\n",d5, d6);
				printf("\n");
				substring(37,51,line);
			}
			if((strncmp(line, "Temperature:",strlen("Temperature:")) == 0)
			|| (strncmp(line, "   Humidity:",strlen("   Humidity:")) == 0)
			|| (strncmp(line, "  Dew Point:",strlen("  Dew Point:")) == 0)){
				//sscanf(line,"%s %s %s %s %s %s %s %s %s",d1,d2,d3,d4,d5,d6,d7,d8,d9);
                		//printf("Temperature:\t%s\t%s\n",d2, d9);
				substring(12,17,line);
				substring(44,49,line);
			}	
		}
		i++;
		fclose(fp);
	}
return(0);
}
